home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Other / upsd / ups_folder / common.h next >
Encoding:
C/C++ Source or Header  |  1991-06-27  |  2.3 KB  |  74 lines

  1. /*
  2. **    c o m m o n . h
  3. **
  4. **    common header file for UPS monitor daemon
  5. **
  6. **    Arthur W. Neilson III
  7. **    art@pilikia.pegasus.com
  8. **    Sat Mar 30 1991
  9. */
  10.  
  11. #include <stdio.h>
  12. #include <string.h>
  13. #include <fcntl.h>
  14. #include <time.h>
  15. /*
  16. #include <std.h>
  17. */
  18. #include <sys/types.h>
  19. #include <sys/tty.h>
  20. #include <sys/signal.h>
  21. #include <sys/stat.h>
  22.  
  23. #include "version.h"
  24.  
  25. #define ERR        -1        /* error return value */
  26. #define SH        "/bin/sh"    /* shell to exec shutdown command */
  27. #define WALL        "/bin/wall"    /* utility to broadcast messages */
  28. #define CONSOLE        "/dev/console"    /* console device */
  29. #define ROOT        "/"        /* root directory for chdir */
  30. #define SECS_PER_MIN    60        /* number of secs in a minute */
  31. #define MAX_TIME    30        /* maximum delay time allowed */
  32. #define LOG_PERMS    0600        /* logfile permissions on create */
  33. #define LOG_FLAGS    O_WRONLY | O_APPEND    /* logfile open flags */
  34.  
  35. /* default tuneable parameter values */
  36. #define UPS_PORT    "/dev/cub"    /* UPS port device name */
  37. #define UPS_SHUT    "/etc/UPS/upsdown.csh"    /* shutdown command */
  38. #define UPS_LOG        "./upslog"    /* UPS log file pathname */
  39. #define UPS_FAIL    "./upsfail"     /* UPS fail message file name */
  40. #define UPS_REST    "./upsrest"     /* UPS restore message file name */
  41. #define UPS_TIME    1        /* default delay time (minutes) */
  42. #define UPS_INTERVAL    10        /* poll interval time (seconds) */
  43.  
  44. /* environment variable names */
  45. #define UPSPORT        "UPSPORT"
  46. #define UPSSHUT        "UPSSHUT"
  47. #define UPSLOG        "UPSLOG"
  48. #define UPSFAIL        "UPSFAIL"
  49. #define UPSREST        "UPSREST"
  50. #define UPSTIME        "UPSTIME"
  51.  
  52. /* UPS log messages */
  53. #define START_MSG    "UPS daemon started"
  54. #define OPEN_MSG    "Error opening UPS port"
  55. #define BATTERY_MSG    "UPS switch to battery backup"
  56. #define ONLINE_MSG    "UPS switch to online power"
  57. #define SHUTDOWN_MSG    "Shutdown command executed"
  58. #define TERM_MSG    "Caught termination signal"
  59.  
  60. /* common globals */
  61. extern char    *ups_port;        /* UPS device name */
  62. extern char    *ups_shut;        /* system shutdown command */
  63. extern char    *ups_log;        /* UPS log file name */
  64. extern char    *ups_fail;        /* UPS failure message file name */
  65. extern char    *ups_rest;        /* UPS restore message file name */
  66. extern int    ups_time;        /* delay time before shutdown */
  67. extern int    ups_fd;            /* UPS port descriptor */
  68. extern int    log_fd;            /* log file descriptor */
  69. extern int    interval;
  70. extern int    state;            /* state of ups */
  71.  
  72. #define UPS_LINE    0
  73. #define UPS_BATTERY    1    
  74.